<?php namespace Config;

// Create a new instance of our RouteCollection class.
$routes = Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
	require SYSTEMPATH . 'Config/Routes.php';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(false);
//i chnaged above after reading foundation book 
//$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.

/*-------my setup below---*/

$routes->get('setUp','Setup::setUpForm');
$routes->post('setUpDo','Setup::process');



$routes->get('/', 'Home::index');
$routes->get('test','Home::test');
/*---------new products-----------------form,controller,models--*/
$routes->get('addProduct','Product::productAddForm');
$routes->post('addProduct','Product::addProductDo');
$routes->get('showProducts','Product::getProducts');
$routes->get('productCat/productInfo/(:segment)', 'Product::prodInfo/$1');
$routes->get('editProducts','Product::displayProdsToEdit');
$routes->get('editOneProduct/(:segment)','Product::editOneProduct/$1');
$routes->post('editProductDo','Product::processEditProduct'); 
$routes->get('removeProduct','Product::delProdForm');
$routes->post('delProduct','Product::delProductDo');
$routes->get('productCat/(:segment)','Product::getCategory/$1');


/* -----  gallery -----------------------   */

$routes->get('showGallery','Gallery::countGallery');
$routes->get('countGallery','Gallery::countGallery');
$routes->get('displayGallery','Gallery::displayGallery');
$routes->get('addGallery','Gallery::galleryAddForm');
$routes->post('addGallery','Gallery::addGalleryDo');
$routes->get('delGallery','Gallery::delGalleryForm');
$routes->post('delGallery','Gallery::delGalleryDo');



/* -------------------------------------------------  */



/*-------------blog----------------------------------*/
$routes->get('dependencyInjection','Blog::altMethod');
$routes->get('newblog', 'Blog::blogForm');
$routes->get('editBlogs','Blog::editBlogForm');
$routes->get('editOneBlog/(:segment)','Blog::editBlog/$1');
$routes->post('doEditBlog','Blog::processEditBlog');
$routes->post('newblog','Blog::newBlogArticle');
$routes->get('removeBlog','Blog::delBlogForm');
$routes->post('delBlog','Blog::delBlog');
$routes->get('blogs','Blog::doPaginate');
$routes->get('blogArticle/(:segment)', 'Blog::showArticle/$1');
$routes->get('linkPdf/(:segment)','ProducePDF::getPdf/$1');

/*------------------------------------------------*/

/*--------------------login, admin----------------*/


$routes->get('admin','Login::admin');
$routes->get('blackcat','Login::login');
$routes->post('login','Login::credentials');
$routes->get('logout','Login::logout');

/*-------------------------------------*/

//$routes->post('contact','Home::getMail');

$routes->post('contact','Sendmail::processform'); 
$routes->get('spam','Spam::spam');
$routes->get('noPage','Pages::nopage');
$routes->get('(:any)', 'Pages::showme/$1');



/**
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
	require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
